<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //es6继承 先声明父类，再声明子类，通过extends继承方法,通过super()继承属性
        //声明父类
        class User {
            constructor(name, password) {
                this.name = name
                this.password = password
            }
            showName() {
                console.log('用户名称', this.name);
            }
            showPass() {
                console.log('用户密码', this.password);
            }
        }
        class VipUser extends User {
            constructor(name, password, level) {
                super(name, password)
                this.level = level
            }
            showLevel() {
                console.log('用户等级', this.level);
            }
        }

        var vip = new VipUser('admin', '123456', 3)
        vip.showName()
        vip.showPass()
        vip.showLevel()
    </script>
</body>

</html>